package com.xz.danhuaapi.service.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xz.danhuaapi.common.ErrorCode;
import com.xz.danhuaapi.exception.ThrowUtils;
import com.xz.danhuaapi.mapper.InterfaceInfoMapper;
import com.xz.danhuaapicommon.model.entity.InterfaceInfo;
import com.xz.danhuaapicommon.service.InnerInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author xuzhou
 * @version 1.0
 * @createTime 2024-08-01
 * @description
 */
@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;

    @Override
    public InterfaceInfo getInvokeInterfaceInfo(String url, String method) {
        ThrowUtils.throwIf(StringUtils.isAnyBlank(url, method), ErrorCode.PARAMS_ERROR);
        QueryWrapper<InterfaceInfo> interfaceInfoQueryWrapper = new QueryWrapper<>();
        interfaceInfoQueryWrapper.eq("url", url);
        interfaceInfoQueryWrapper.eq("method", method);
        return interfaceInfoMapper.selectOne(interfaceInfoQueryWrapper);
    }
}
